package com.itany.mybatis;

import com.itany.mybatis.dao.UserDao;
import com.itany.mybatis.entity.User;
import com.itany.mybatis.factory.ObjectFactory;
import com.itany.mybatis.tm.TransactionManager;
import org.junit.Test;

/**
 * Description: 类的描述
 * Author: liudaolin@itany.com
 * Date: 2021/07/20 13:37
 * Version: 1.0 版本信息
 */
public class Test03 {

    @Test
    public void f1(){
//        TransactionManager tm = new MyBatisTransactionManagerImpl();
//        UserDao userDao = MyBatisUtil.getSession().getMapper(UserDao.class);
        TransactionManager tm = ObjectFactory.getObj("tm");
        UserDao userDao = ObjectFactory.getObj("userDao");
        try {
            tm.begin();

            User user = new User();
            user.setName("aaaaa");
            user.setPwd("qqqqq");
            user.setAge(22);
            userDao.insertUser3(user);

            tm.commit();
        } catch (Exception e) {
            e.printStackTrace();
            tm.rollback();
        }
    }

}
